home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / sound / fmsyn104.zip / STMB.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-13  |  5KB  |  133 lines

  1. (* STMB.PAS -- Pascal Programming interface for FMSYNTH.DRV
  2.  *             Copyright (c) 1993 by Jamie O'Connell
  3.  *
  4.  * Currently four functions are defined: GetTimbre, SetTimbre, GetPercMap,
  5.  * ans SetPercMap.
  6.  * 
  7.  * Get Timbre retrieves the Timbre parameters from the specified location.
  8.  *
  9.  * SetTimbre will change the sound of an instrument in either working 
  10.  * storage or the sound of an instrument stored within a RAM Timbre Bank.
  11.  * 
  12.  * GetPercMap and SetPercMap perform equivalent functions on the internal
  13.  * percussion map: which note plays which percussion timbre at what pitch.
  14.  *
  15.  * Working storage is the current version of a Timbre stored on a 
  16.  * per-channel basis.  It is the version of the timbre which is used to
  17.  * sound a voice for the channel when a note is to be played. The working 
  18.  * storage is overwritten by Bank storage whenever a program change is 
  19.  * received for the channel.
  20.  *
  21.  * The RAM Timbre bank is either the internal Timbre Bank, or one which 
  22.  * has been loaded from a file.  In either case it is volatile storage
  23.  * which is overwritten when the bank is reloaded.
  24.  *)
  25.  
  26. unit STmb;
  27.  
  28. interface
  29.  
  30. uses WinTypes, WinProcs;
  31.  
  32. const
  33.   TMB_WORKING_STORAGE  =  0;
  34.   TMB_BANK_STORAGE     =  1;
  35.   TMB_BANK_PERCUSSION  =  2;
  36.  
  37.   FIRSTDRUMNOTE = 35;
  38.   LASTDRUMNOTE  = 81;
  39.   NUMDRUMNOTES  = (LASTDRUMNOTE - FIRSTDRUMNOTE + 1);
  40.  
  41. Type
  42.  
  43. (* The timbre definition (IBK - SBI Format) *)
  44.  
  45.   PTmbRec = ^TmbRec;
  46.   TmbRec  = Record
  47.     MSndChr : Byte;
  48.     CSndChr : Byte;
  49.     MKSLOut : Byte;
  50.     CKSLOut : Byte;
  51.     MAtkDcy : Byte;
  52.     CAtkDcy : Byte;
  53.     MSusRel : Byte;
  54.     CSusRel : Byte;
  55.     MWavSel : Byte;
  56.     CWavSel : Byte;
  57.     FDBkCon : Byte;
  58.     PercVoc : Byte;
  59.     Transps : ShortInt;
  60.     Future1 : Byte;
  61.     Future2 : Word;
  62.   end;
  63.  
  64. PercElem = Record
  65.     patch : Byte;
  66.     note  : Byte;
  67.   end;
  68.  
  69.  
  70. PPercMap = ^PercMap;
  71. PercMap  = Array [1..NUMDRUMNOTES] of PercElem;
  72.  
  73. (* The percussion map provides info for each pecussion MIDI key
  74.  * To access (retrieve or send) the Percussion map you create an
  75.  * array of these things: PERCMAP percMap[NUMDRUMNOTES];
  76.  * and pass it to GetPercMap or SetPercMap.  The buffer must be at least
  77.  * sizeof(PERCMAP) * NUMDRUMNOTES = 94 bytes large.
  78.  *)
  79.  
  80. Procedure GetPercMap(lpPM: PPercMap); Far;
  81. Procedure SetPercMap(lpPM: PPercMap); Far;
  82.  
  83. Function GetTimbre(wLoc: Word; lpTmb: PTmbRec; wSrc: Word): Word;  Far;
  84. Function SetTimbre(wLoc: Word; lpTmb: PTmbRec; wDest: Word): Word; Far;
  85.  
  86. (*
  87.  *  DESCRIPTION
  88.  *
  89.  *  wLoc - If the Destination (wDest) or Source (wSrc) is TMB_WORKING_STORAGE,
  90.  *         then wLoc is the channel number (0 based) for storing the Timbre.
  91.  *         If the Destination is TMB_BANK_STORAGE, then the most
  92.  *         significant byte of wLoc (HIBYTE(wLoc)) is the Bank number
  93.  *         (valid values: 0 - 4), and the least significant byte is the
  94.  *         timbre number (0-127).
  95.  *         If the destination is TMB_PERC_BANK, the Bank number is ignored
  96.  *         (there is only one percussion bank), and the LSB is the timbre
  97.  *         number (0-46).
  98.  *
  99.  *  lpTmb  A far pointer to a TIMBRE structure, defining the new timbre to
  100.  *         store.  The structure should be the full 16 bytes in length.
  101.  *
  102.  *  wSrc   This value determines how wLoc is interpreted when retrieving
  103.  *         the timbre.  If wSrc is TMB_WORKING_STORAGE the timbre is retrieved
  104.  *         from working storage (wLoc is a channel number). If wSrc is
  105.  *         TMB_BANK_STORAGE, the timbre is retrieved from the specified
  106.  *         bank and timbre slot (wLoc is the combination of Bank & Timbre#).
  107.  *
  108.  *  wDest  This value determines how wLoc is interpreted and the final
  109.  *         destination for the timbre.  If wDest is ST_WORKING_STORAGE the
  110.  *         channel timbre info is updated, and future voices on channel will
  111.  *         sound this timbre. If wDest is ST_BANK_STORAGE, both the Bank
  112.  *         Timbre, and any channels set to this Bank and Timbre are updated.
  113.  *         Any future notes playing this bank and timbre will sound the
  114.  *         timbre.
  115.  *
  116.  *  Return Value
  117.  *         If all goes well, 0 is returned, otherwise a non-zero value is
  118.  *         returned indicating, an incorrect or out-of-range parameter.
  119.  *         The values within the TIMBRE structure itself are not checked
  120.  *         for validity, but stored as supplied.
  121.  *)
  122.  
  123. implementation
  124.  
  125. Procedure GetPercMap;  external 'FMSYNTH' index  9;
  126. Procedure SetPercMap;  external 'FMSYNTH' index 10;
  127.  
  128. Function GetTimbre;    external 'FMSYNTH' index  7;
  129. Function SetTimbre;    external 'FMSYNTH' index  8;
  130.  
  131. end.
  132.  
  133.